<html>
<head><meta charset="utf-8"><title>rustc_targeted_inline · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html">rustc_targeted_inline</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="181644665"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644665" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644665">(Nov 22 2019 at 14:55)</a>:</h4>
<p><span class="user-mention" data-user-id="124288">@oli</span> <span class="user-mention" data-user-id="125250">@Wesley Wiser</span>  So I was thinking of following up <a href="https://github.com/rust-lang/rust/issues/66282" target="_blank" title="https://github.com/rust-lang/rust/issues/66282">#66282</a> with a targeted inliner. My idea is that we visit all the BBs and on a function call, we look for <code>#[rustc_targeted_inline]</code> on the <code>def_id</code> and then we do the inlining by adding some basic blocks to the end (I'll need to look for other subtleties). This is done in a one-shot fashion; we don't compute SCC or try to recursively inline. Thoughts?</p>



<a name="181644790"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644790" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644790">(Nov 22 2019 at 14:57)</a>:</h4>
<p>I'm not opposed and it would be great to see some work done in this direction. I do think it would be nice if we only had 1 inliner though.</p>



<a name="181644802"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644802" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644802">(Nov 22 2019 at 14:57)</a>:</h4>
<p>And I feel like there's something relatively simple that's wrong with the current one</p>



<a name="181644873"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644873" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644873">(Nov 22 2019 at 14:58)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> I agree with the end goal, but I was thinking that this would be a temporary thing while we figure out the general case</p>



<a name="181644893"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644893" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644893">(Nov 22 2019 at 14:58)</a>:</h4>
<p>mainly to improve <code>?</code></p>



<a name="181644904"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644904" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644904">(Nov 22 2019 at 14:58)</a>:</h4>
<p>The only real difference between what it currently does and what you've outlined above is that it doesn't only target <code>#[rustc_targeted_inline]</code></p>



<a name="181644944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644944">(Nov 22 2019 at 14:59)</a>:</h4>
<p>I think all of the rest of the code is going to be pretty much the same</p>



<a name="181644948"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181644948" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181644948">(Nov 22 2019 at 14:59)</a>:</h4>
<p>modulo bugs</p>



<a name="181645084"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181645084" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181645084">(Nov 22 2019 at 15:00)</a>:</h4>
<p>To be clear, I'm not saying "don't do it". I just think that in the time it will take to write the new one, you could probably find and fix the issues with the current one :)</p>



<a name="181645255"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181645255" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181645255">(Nov 22 2019 at 15:02)</a>:</h4>
<p><span class="user-mention" data-user-id="125250">@Wesley Wiser</span> oh; I'm a bit surprised... I assumed the current inliner uses SCC to inline recursively etc.</p>



<a name="181645813"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181645813" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181645813">(Nov 22 2019 at 15:06)</a>:</h4>
<p>Yea I'd rather not build a second inliner that we'll have to maintain</p>



<a name="181645835"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181645835" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181645835">(Nov 22 2019 at 15:06)</a>:</h4>
<p>let's "just" fix the existing one</p>



<a name="181645998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181645998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181645998">(Nov 22 2019 at 15:08)</a>:</h4>
<p>is there somewhere I can read about the issues with the current inliner?</p>



<a name="181646169"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181646169" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181646169">(Nov 22 2019 at 15:10)</a>:</h4>
<p>other than the panics happening when you run it on stage 2, I don't think so</p>



<a name="181646274"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181646274" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Wesley Wiser <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181646274">(Nov 22 2019 at 15:11)</a>:</h4>
<blockquote>
<p>@Wesley Wiser oh; I'm a bit surprised... I assumed the current inliner uses SCC to inline recursively etc.</p>
</blockquote>
<p>Nope, it should and niko wants it to but currently it just calls <code>tcx.optimized_mir(callee_def_id)</code> and handles the cycle error by bailing out.</p>



<a name="181646387"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline/near/181646387" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> centril <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/rustc_targeted_inline.html#181646387">(Nov 22 2019 at 15:12)</a>:</h4>
<p>Sounds like I'd need to go on a fishing expedition then :P</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>